using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebTools.UI.WebControls
{
	[ToolboxData("<{0}:TextboxLabel runat=server></{0}:TextboxLabel>")]
	public class TextboxLabel : WebControlLabel<TextBox>
	{
		public override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
		{
			if (!this.ReadOnly)
			{
				return base.LoadPostData(postDataKey, postCollection);
			}
			return false;
		}

		protected override void SetCustomProperties(TextBox control)
		{
			control.MaxLength = this.MaxLength;
			control.TextMode = this.TextMode;
			control.Columns = this.Columns;
			control.ReadOnly = this.ReadOnly;
			control.Rows = this.Rows;
			control.ValidationGroup = this.ValidationGroup;
			control.Wrap = this.Wrap;
			control.TextChanged += new EventHandler(this.InternalTextChanged);
		}

		#region Properties
		[DefaultValue(0)]
		[Description("")]
		[Themeable(false)]
		[Category("Behavior")]
		public virtual int MaxLength
		{
			get
			{
				object obj = this.ViewState["MaxLength"];
				if (obj != null)
				{
					return (int)obj;
				}
				return 0;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				this.ViewState["MaxLength"] = value;
			}
		}

		[Description("")]
		[DefaultValue(0)]
		[Themeable(false)]
		[Category("Behavior")]
		public virtual TextBoxMode TextMode
		{
			get
			{
				object obj = this.ViewState["Mode"];
				if (obj != null)
				{
					return (TextBoxMode)obj;
				}
				return TextBoxMode.SingleLine;
			}
			set
			{
				if ((value < TextBoxMode.SingleLine) || (value > TextBoxMode.Password))
				{
					throw new ArgumentOutOfRangeException("value");
				}
				this.ViewState["Mode"] = value;
			}
		}

		[DefaultValue(false)]
		[Category("Behavior")]
		[Themeable(false)]
		[Description("")]
		public virtual bool CausesValidation
		{
			get
			{
				object obj = this.ViewState["CausesValidation"];
				if (obj != null)
				{
					return (bool)obj;
				}
				return false;
			}
			set
			{
				this.ViewState["CausesValidation"] = value;
			}
		}

		[Description("")]
		[Category("Appearance")]
		[DefaultValue(0)]
		public virtual int Columns
		{
			get
			{
				object obj = this.ViewState["Columns"];
				if (obj != null)
				{
					return (int)obj;
				}
				return 0;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentOutOfRangeException("Columns");
				}
				this.ViewState["Columns"] = value;
			}
		}

		[DefaultValue(false)]
		[Bindable(true)]
		[Description("")]
		[Themeable(false)]
		[Category("Behavior")]
		public virtual bool ReadOnly
		{
			get
			{
				object obj = this.ViewState["ReadOnly"];
				if (obj != null)
				{
					return (bool)obj;
				}
				return false;
			}
			set
			{
				this.ViewState["ReadOnly"] = value;
			}
		}

		[Description("")]
		[DefaultValue(0)]
		[Themeable(false)]
		[Category("Behavior")]
		public virtual int Rows
		{
			get
			{
				object obj = this.ViewState["Rows"];
				if (obj != null)
				{
					return (int)obj;
				}
				return 0;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentOutOfRangeException("Rows");
				}
				this.ViewState["Rows"] = value;
			}
		}

		[Category("Behavior")]
		[Themeable(false)]
		[DefaultValue("")]
		[Description("")]
		public virtual string ValidationGroup
		{
			get
			{
				string text = (string)this.ViewState["ValidationGroup"];
				if (text != null)
				{
					return text;
				}
				return string.Empty;
			}
			set
			{
				this.ViewState["ValidationGroup"] = value;
			}
		}

		[DefaultValue(true)]
		[Category("Layout")]
		[Description("")]
		public virtual bool Wrap
		{
			get
			{
				object obj = this.ViewState["Wrap"];
				if (obj != null)
				{
					return (bool)obj;
				}
				return true;
			}
			set
			{
				this.ViewState["Wrap"] = value;
			}
		}
		#endregion
	}
}
